import { encodeBase64 } from "@/utils/base64";
import { preferences } from "@/config/preference";
import { useAccessStore } from "@/store";

interface AuthRequests {
  Authorization: string;
  "Blade-Auth"?: string;
}

export function setHeaders(): AuthRequests {
  const accessStore = useAccessStore();
  let authStr = preferences.system.authClientID + ":" + preferences.system.authClientSecret;
  const result: AuthRequests = { Authorization: "Basic " + encodeBase64(authStr) };
  if (accessStore.accessToken) {
    result["Blade-Auth"] = "bearer " + accessStore.accessToken;
  }
  return result;
}
